package com.app.biz.service.impl;

import cn.hutool.core.util.IdUtil;
import com.app.biz.domain.BizIndustryPriceNewsDaily;
import com.app.biz.domain.formal.BizKeyAreasValuesFormal;
import com.app.biz.mapper.BizIndustryPriceNewsDailyMapper;
import com.app.biz.mapper.BizKeyAreasValuesFormalMapper;
import com.app.biz.service.*;
import com.app.common.core.domain.AjaxResult;
import com.app.common.core.domain.entity.SysDictData;
import com.app.common.utils.DictUtils;
import com.app.common.utils.SecurityUtils;
import com.app.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class BizIndustryPriceNewsDailyServiceImpl implements IBizIndustryPriceNewsDailyService {

    @Autowired
    private BizIndustryPriceNewsDailyMapper bizIndustryPriceNewsDailyMapper;


    @Override
    public BizIndustryPriceNewsDaily selectBizIndustryPriceNewsDailyByBaseId(String baseId) {
        return bizIndustryPriceNewsDailyMapper.selectBizIndustryPriceNewsDailyByBaseId(baseId);
    }

    @Override
    public List<BizIndustryPriceNewsDaily> selectBizIndustryPriceNewsDailyList(BizIndustryPriceNewsDaily bizIndustryPriceNewsDaily) {
        return bizIndustryPriceNewsDailyMapper.selectBizIndustryPriceNewsDailyList(bizIndustryPriceNewsDaily);
    }

    @Override
    public int insertBizIndustryPriceNewsDaily(BizIndustryPriceNewsDaily bizIndustryPriceNewsDaily) {

        bizIndustryPriceNewsDaily.setBaseId(IdUtil.fastUUID());
        bizIndustryPriceNewsDaily.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        bizIndustryPriceNewsDaily.setCreateTime(new Date());
        return bizIndustryPriceNewsDailyMapper.insertBizIndustryPriceNewsDaily(bizIndustryPriceNewsDaily);
    }

    @Override
    public int updateBizIndustryPriceNewsDaily(BizIndustryPriceNewsDaily bizIndustryPriceNewsDaily) {
        bizIndustryPriceNewsDaily.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        bizIndustryPriceNewsDaily.setUpdateTime(new Date());
        return bizIndustryPriceNewsDailyMapper.updateBizIndustryPriceNewsDaily(bizIndustryPriceNewsDaily);
    }

    @Override
    public int deleteBizIndustryPriceNewsDailyByBaseIds(String[] baseIds) {
        return bizIndustryPriceNewsDailyMapper.deleteBizIndustryPriceNewsDailyByBaseIds(baseIds);
    }

    @Override
    public int deleteBizIndustryPriceNewsDailyByBaseId(String baseId) {
        return bizIndustryPriceNewsDailyMapper.deleteBizIndustryPriceNewsDailyByBaseId(baseId);
    }

    @Override
    public BizIndustryPriceNewsDaily getBizIndustryPriceNewsDaily() {
        BizIndustryPriceNewsDaily bizIndustryPriceNewsDaily = new BizIndustryPriceNewsDaily();
        List<BizIndustryPriceNewsDaily> list = bizIndustryPriceNewsDailyMapper.selectBizIndustryPriceNewsDailyList(bizIndustryPriceNewsDaily);
        return !CollectionUtils.isEmpty(list) ? list.get(0) : new BizIndustryPriceNewsDaily();

    }
}
